package com.byq.mm.abstractx.cluster.provider;

import java.util.HashMap;
import java.util.Map;


import com.byq.mm.abstractx.cluster.client.ClusterClient;
import com.byq.mm.abstractx.cluster.client.UnsupportedClusterClient;
import com.byq.mm.abstractx.cluster.server.ClusterServer;
import com.byq.mm.abstractx.cluster.server.UnsupportedClusterServer;
import com.byq.mm.application.cluster.provider.LevelControlProvider;
import com.byq.mm.application.cluster.provider.LocationProvider;
import com.byq.mm.application.cluster.provider.ObdProvider;
import com.byq.mm.application.cluster.provider.OnoffProvider;
import com.byq.mm.application.cluster.provider.PictureProvider;
import com.byq.mm.application.cluster.provider.PlayerProvider;
import com.byq.mm.application.cluster.provider.TunnelProvider;
import com.byq.mm.cluster.provider.SimpleSensorProvider;


public class ClusterProviderManager {
	static Map<String, ClusterProvider> providers = new HashMap<String, ClusterProvider>();
	static{

		register(new LocationProvider());
		register(new PictureProvider());
		register(new OnoffProvider());
		register(new LevelControlProvider());
		register(new SimpleSensorProvider());
		register(new PlayerProvider());
		register(new ObdProvider());
		register(new TunnelProvider());
	}
	private ClusterProviderManager(){
	
	}
	
	public static Class<? extends ClusterClient> getClientType(String clusterId){
		ClusterProvider p = providers.get(clusterId);
		if(p == null)
			return UnsupportedClusterClient.class;
		return p.getCusterClientType();
	}
	public static Class<? extends ClusterServer> getServerType(String clusterId){
		ClusterProvider p = providers.get(clusterId);
		if(p == null)
			return UnsupportedClusterServer.class;
		return p.getCusterServerType();
	}
	public static void register(ClusterProvider provider){
		providers.put(provider.getClusterIdentifier(), provider);
	
	}
}
